package com.cw.jeeyt.dao.impl.api;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;

import com.cw.jeeyt.common.Order;
import com.cw.jeeyt.dao.intf.api.ApiFacadeObjEnumDao;
import com.cw.jeeyt.dao.mapper.api.ApiFacadeObjEnumMapper;
import com.cw.jeeyt.dao.model.api.ApiFacadeObjEnumDo;
import com.cw.lang.common.utils.PageUtil;
import com.cw.lang.common.pagehelper.PageHelper;
import com.cw.lang.mybatis.dto.PageInfo;

/**
 * 枚举对象信息表 dao数据库操作接口
 *
 * @author chenw
 * @version 1.0.0
 */
@Repository
public class ApiFacadeObjEnumDaoImpl implements ApiFacadeObjEnumDao {
    @Autowired
    private ApiFacadeObjEnumMapper apiFacadeObjEnumMapper;

    /**
     * 新增枚举对象信息表
     *
     * @param apiFacadeObjEnum
     * @return 整数
     */
    public Integer insert(ApiFacadeObjEnumDo apiFacadeObjEnum) {
        return apiFacadeObjEnumMapper.insert(apiFacadeObjEnum);
    }

    /**
     * 新增枚举对象信息表不为空的字段
     *
     * @param apiFacadeObjEnum
     * @return 整数
     */
    public Integer insertSelective(ApiFacadeObjEnumDo apiFacadeObjEnum) {
        return apiFacadeObjEnumMapper.insertSelective(apiFacadeObjEnum);
    }

    /**
     * 删除枚举对象信息表
     *
     * @param apiFacadeObjEnum
     */
    public void delete(ApiFacadeObjEnumDo apiFacadeObjEnum) {
        apiFacadeObjEnumMapper.delete(apiFacadeObjEnum);
    }

    /**
     * 根据父id删除枚举对象信息
     *
     * @param parentId
     * @throws Exception
     */
    public Integer deleteByParentId(Long parentId) {
        return apiFacadeObjEnumMapper.deleteByParentId(parentId);
    }

    /**
     * 修改枚举对象信息表不为null的字段
     *
     * @param apiFacadeObjEnum
     */
    public void updateSelective(ApiFacadeObjEnumDo apiFacadeObjEnum) {
        apiFacadeObjEnumMapper.updateSelective(apiFacadeObjEnum);
    }

    /**
     * 修改枚举对象信息表
     *
     * @param apiFacadeObjEnum
     */
    public void update(ApiFacadeObjEnumDo apiFacadeObjEnum) {
        apiFacadeObjEnumMapper.update(apiFacadeObjEnum);
    }

    /**
     * 根据主键查询枚举对象信息表
     *
     * @return 枚举对象信息表
     */
    public ApiFacadeObjEnumDo getById(Long id) {
        return apiFacadeObjEnumMapper.getById(id);
    }

    /**
     * 查询所有枚举对象信息表
     *
     * @return 枚举对象信息表集合
     */
    public List<ApiFacadeObjEnumDo> queryApiFacadeObjEnumList() {
        return apiFacadeObjEnumMapper.queryApiFacadeObjEnumList();
    }

    /**
     * 分页查询枚举对象信息表
     *
     * @param apiFacadeObjEnum 查询条件
     * @param startRow 开始条数
     * @param pageSize 每页长度
     * @return 枚举对象信息表集合
     */
    public PageInfo<ApiFacadeObjEnumDo> queryByPage(ApiFacadeObjEnumDo apiFacadeObjEnum, Integer startRow,
        Integer pageSize, Order order) {
        PageHelper.startPage(PageUtil.calPageNum(startRow, pageSize), pageSize);
        return new PageInfo<>(apiFacadeObjEnumMapper.queryByPage(apiFacadeObjEnum, order));
    }

    /**
     * 根据父id查询枚举对象信息
     *
     * @param parentId
     * @return
     */
    public List<ApiFacadeObjEnumDo> queryListByParentId(Long parentId) {
        return apiFacadeObjEnumMapper.queryListByParentId(parentId);
    }

    /**
     * 根据枚举编码和枚举名称查询枚举信息
     *
     * @param enumCode
     * @param enumName
     * @return
     */
    public ApiFacadeObjEnumDo queryEnumByCodeAndName(String enumCode, String enumName, String enumPackage) {
        return apiFacadeObjEnumMapper.queryEnumByCodeAndName(enumCode, enumName, enumPackage);
    }
}
